*--------------------------------------------------------------*
*PART ONE!!!*
*--------------------------------------------------------------*
clear all
set more off

*--------------------------------------------------------------*
* 1. Load Data
*--------------------------------------------------------------*
use "Data/AnalysisData/final_analysis_data.dta", clear

*--------------------------------------------------------------*
* 2. Create 50-cent Increase Treatment Variable
*--------------------------------------------------------------*
sort state year
gen lag_state_min_wage = state_min_wage[_n-1] if state == state[_n-1]
gen change_in_min_wage = state_min_wage - lag_state_min_wage
gen treat_year = .
gen treated = 0

levelsof state, local(states)
foreach s of local states {
    quietly {
        su year if state == "`s'" & change_in_min_wage >= 0.5 & year > 2010, meanonly
        if r(N) > 0 {
            replace treat_year = r(min) if state == "`s'"
            replace treated = 1 if state == "`s'"
        }
    }
}

*--------------------------------------------------------------*
* 3. Set Panel Structure
*--------------------------------------------------------------*
encode state, gen(state_id)
xtset state_id year

cap which csdid
ssc install csdid, replace

cap which drdid
ssc install drdid, replace

* Run csdid
csdid employment_population_ratio ///
    unemployment_rate disposable_income_, ///
    ivar(state_id) time(year) gvar(treat_year) ///
    method(dripw) wboot reps(500) seed(12345)

ssc install estout, replace
* Immediately store the regression output
eststo csdid_main

* Now run csdid_estat simple just to *view* ATT
csdid_estat simple

* Now export using esttab (referring to the stored regression, not simple estat)
esttab csdid_main using "Output/Results/Tables/att_summary_table.txt", ///
    cells(b(fmt(3)) se(par fmt(3))) ///
    label noobs replace


*--------------------------------------------------------------*
* 6. Run Event Study and Save Results
*--------------------------------------------------------------*
csdid_estat event
matrix M = r(table)'
clear
svmat M, names(col)

*--------------------------------------------------------------*
* 7. Clean Event Study Output
*--------------------------------------------------------------*
gen eventtime = -2 + _n   // Start approx
replace eventtime = -99 if _n == 1   // Pre_avg
replace eventtime = 99 if _n == 2    // Post_avg

rename b attgt
rename se se_attgt

keep if inrange(eventtime, 1, 7)
replace eventtime = eventtime - 5

* Save cleaned event study table
capture mkdir "Output/Results/Tables"
outsheet eventtime attgt se_attgt using "Output/Results/Tables/event_study_table.csv", comma replace

* (Optional) You can manually list the results to screen
list eventtime attgt se_attgt

*--------------------------------------------------------------*
* 8. Plot Event Study
*--------------------------------------------------------------*
capture mkdir "Output/Results/Figures"

twoway ///
    (rarea attgt se_attgt eventtime, color(gs12)) ///
    (connected attgt eventtime, lcolor(blue) mcolor(blue)) ///
    , ///
    yline(0, lcolor(black)) ///
    xline(0, lpattern(dash)) ///
    ylabel(, grid) ///
    xlabel(-4(1)2, grid) ///
    title("Effect of $0.50 Minimum Wage Increase on Employment") ///
    ytitle("ATT on Employment-Population Ratio (%)") ///
    xtitle("Years Relative to Treatment") ///
    legend(off)

* Export the graph
graph export "Output/Results/Figures/event_study_plot.png", replace
graph export "Output/Results/Figures/event_study_plot.pdf", replace

*--------------------------------------------------------------*
* DONE!
*--------------------------------------------------------------*









*--------------------------------------------------------------*
* PART TWO!!!!!
*--------------------------------------------------------------*
clear all
set more off

*--------------------------------------------------------------*
* 1. Load Final Dataset
*--------------------------------------------------------------*
use "Data/AnalysisData/final_analysis_data.dta", clear

*--------------------------------------------------------------*
* 2. Create 50-cent Increase Treatment Variable
*--------------------------------------------------------------*
sort state year
gen lag_state_min_wage = state_min_wage[_n-1] if state == state[_n-1]
gen change_in_min_wage = state_min_wage - lag_state_min_wage
gen treat_year = .
gen treated = 0

levelsof state, local(states)
foreach s of local states {
    quietly {
        su year if state == "`s'" & change_in_min_wage >= 0.5 & year > 2010, meanonly
        if r(N) > 0 {
            replace treat_year = r(min) if state == "`s'"
            replace treated = 1 if state == "`s'"
        }
    }
}

*--------------------------------------------------------------*
* 3. Set Panel Structure
*--------------------------------------------------------------*
encode state, gen(state_id)
xtset state_id year

*--------------------------------------------------------------*
* 4. Run Staggered DiD (csdid) with Controls
* Dependent variable: labor_force_participation_rate
*--------------------------------------------------------------*
csdid labor_force_participation_rate ///
    unemployment_rate disposable_income_, ///
    ivar(state_id) time(year) gvar(treat_year) ///
    method(dripw) wboot reps(500) seed(12345)

* Immediately store the regression output
eststo lfpr_main

*--------------------------------------------------------------*
* 5. Run and Save Event Study
*--------------------------------------------------------------*
csdid_estat event

matrix M = r(table)'
clear
svmat M, names(col)

gen eventtime = -2 + _n
replace eventtime = -99 if _n == 1   // Pre_avg
replace eventtime = 99 if _n == 2    // Post_avg

rename b attgt
* se is already named se

keep if inrange(eventtime, 1, 7)
replace eventtime = eventtime - 5

*--------------------------------------------------------------*
* 6. Save Event Study Table
*--------------------------------------------------------------*
capture mkdir "Output/Results/Tables"
export delimited using "Output/Results/Tables/event_study_table_lfpr.csv", replace

*--------------------------------------------------------------*
* 7. Plot Event Study
*--------------------------------------------------------------*
capture mkdir "Output/Results/Figures"
twoway ///
    (rarea attgt se eventtime, color(gs12)) ///
    (connected attgt eventtime, lcolor(blue) mcolor(blue)) ///
    , ///
    yline(0, lcolor(black)) ///
    xline(0, lpattern(dash)) ///
    ylabel(, grid) ///
    xlabel(-4(1)2, grid) ///
    title("Effect of $0.50 Minimum Wage Increase on Labor Force Participation") ///
    ytitle("ATT on Labor Force Participation Rate (%)") ///
    xtitle("Years Relative to Treatment") ///
    legend(off)

graph export "Output/Results/Figures/event_study_lfpr.png", replace
graph export "Output/Results/Figures/event_study_lfpr.pdf", replace

* Save ATT Summary Table
capture mkdir "Output/Results/Tables"
csdid_estat simple

esttab lfpr_main using "Output/Results/Tables/att_summary_table_lfpr.txt", ///
    se label b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) replace

	
*--------------------------------------------------------------*
* PART THREE!!!
*--------------------------------------------------------------*
*--------------------------------------------------------------*
* 9. Clean Start for Unemployment Rate Analysis
*--------------------------------------------------------------*
clear all
set more off

* Load Final Data
use "Data/AnalysisData/final_analysis_data.dta", clear

* Rebuild Treatment
sort state year
gen lag_state_min_wage = state_min_wage[_n-1] if state == state[_n-1]
gen change_in_min_wage = state_min_wage - lag_state_min_wage
gen treat_year = .
gen treated = 0

levelsof state, local(states)
foreach s of local states {
    quietly {
        su year if state == "`s'" & change_in_min_wage >= 0.5 & year > 2010, meanonly
        if r(N) > 0 {
            replace treat_year = r(min) if state == "`s'"
            replace treated = 1 if state == "`s'"
        }
    }
}

* Reset Panel
encode state, gen(state_id)
xtset state_id year

*--------------------------------------------------------------*
* 10. Run Staggered DiD: Unemployment Rate
*--------------------------------------------------------------*

* Run csdid for unemployment
csdid unemployment_rate ///
    disposable_income_, ///
    ivar(state_id) time(year) gvar(treat_year) ///
    method(dripw) wboot reps(500) seed(12345)

* Save the regression
eststo unemp_main

* (Optional) look at ATT simple view
csdid_estat simple

* Save ATT table
capture mkdir "Output/Results/Tables"
esttab unemp_main using "Output/Results/Tables/att_summary_table_unemployment.txt", ///
    cells(b(fmt(3)) se(par fmt(3))) label noobs star(* 0.10 ** 0.05 *** 0.01) replace

* Run Event Study
csdid_estat event
matrix M = r(table)'
clear
svmat M, names(col)

gen eventtime = -2 + _n
replace eventtime = -99 if _n == 1
replace eventtime = 99 if _n == 2

rename b attgt
* se already correctly named
keep if inrange(eventtime, 1, 7)
replace eventtime = eventtime - 5

* Plot Event Study
capture mkdir "Output/Results/Figures"
twoway ///
    (rarea attgt se eventtime, color(gs12)) ///
    (connected attgt eventtime, lcolor(blue) mcolor(blue)) ///
    , ///
    yline(0, lcolor(black)) ///
    xline(0, lpattern(dash)) ///
    ylabel(, grid) ///
    xlabel(-4(1)2, grid) ///
    title("Effect of $0.50 Minimum Wage Increase on Unemployment Rate") ///
    ytitle("ATT on Unemployment Rate (%)") ///
    xtitle("Years Relative to Treatment") ///
    legend(off)

* Save Graphs
graph export "Output/Results/Figures/event_study_unemployment.png", replace
graph export "Output/Results/Figures/event_study_unemployment.pdf", replace

* Export Event Study Coefficients as Table
capture mkdir "Output/Results/Tables"
outsheet eventtime attgt se using "Output/Results/Tables/event_study_table_unemployment.txt", replace



**************************
**************************
*START OF ROBUST CHECKS***
**************************
**************************
*EMPLOYMENT
*--------------------------------------------------------------*
* 0. Clean start
*--------------------------------------------------------------*
clear all
set more off

*--------------------------------------------------------------*
* 1. Load Data
*--------------------------------------------------------------*
use "Data/AnalysisData/final_analysis_data.dta", clear

*--------------------------------------------------------------*
* 2. Create 50-cent Increase Treatment Variable
*--------------------------------------------------------------*
sort state year
gen lag_state_min_wage = state_min_wage[_n-1] if state == state[_n-1]
gen change_in_min_wage = state_min_wage - lag_state_min_wage
gen treat_year = .
gen treated = 0

levelsof state, local(states)
foreach s of local states {
    quietly {
        su year if state == "`s'" & change_in_min_wage >= 0.5 & year > 2010, meanonly
        if r(N) > 0 {
            replace treat_year = r(min) if state == "`s'"
            replace treated = 1 if state == "`s'"
        }
    }
}

*--------------------------------------------------------------*
* 3. Set Panel Structure
*--------------------------------------------------------------*
encode state, gen(state_id)
xtset state_id year

* Run csdid
csdid employment_population_ratio ///
    unemployment_rate disposable_income_, ///
    ivar(state_id) time(year) gvar(treat_year) ///
    method(dripw) wboot reps(500) seed(12345)

* Store the results
eststo emp_main






*--------------------------------------------------------------*
* 5. Run Event Study
*--------------------------------------------------------------*
csdid_estat event

* Save event study results from returned matrix
matrix M = r(table)'
clear
svmat M, names(col)

*--------------------------------------------------------------*
* 6. Clean Event Study Output
*--------------------------------------------------------------*
gen eventtime = -2 + _n
replace eventtime = -99 if _n == 1
replace eventtime = 99 if _n == 2
rename b attgt
keep if inrange(eventtime, 1, 7)
replace eventtime = eventtime - 5

*--------------------------------------------------------------*
* 7. Plot Event Study
*--------------------------------------------------------------*
twoway ///
    (rarea attgt se eventtime, color(gs12)) ///
    (connected attgt eventtime, lcolor(blue) mcolor(blue)) ///
    , ///
    yline(0, lcolor(black)) ///
    xline(0, lpattern(dash)) ///
    ylabel(, grid) ///
    xlabel(-4(1)2, grid) ///
    title("Effect of $0.50 Minimum Wage Increase on Employment") ///
    ytitle("ATT on Employment-Population Ratio (%)") ///
    xtitle("Years Relative to Treatment") ///
    legend(off)

*--------------------------------------------------------------*
* 8. Save the Graph
*--------------------------------------------------------------*
graph export "Output/Results/Figures/no_controls_event_study_plot.png", replace

* Save ATT output table
esttab emp_main using "Output/Results/Tables/att_summary_table_no_controls.txt", ///
    se b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) label replace

	
	
	
	
	
*LFPR Robust*

*--------------------------------------------------------------*
* 0. Clean Start
*--------------------------------------------------------------*
clear all
set more off

*--------------------------------------------------------------*
* 1. Load Data
*--------------------------------------------------------------*
use "Data/AnalysisData/final_analysis_data.dta", clear

*--------------------------------------------------------------*
* 2. Create 50-cent Increase Treatment Variable
*--------------------------------------------------------------*
sort state year
gen lag_state_min_wage = state_min_wage[_n-1] if state == state[_n-1]
gen change_in_min_wage = state_min_wage - lag_state_min_wage
gen treat_year = .
gen treated = 0

levelsof state, local(states)
foreach s of local states {
    quietly {
        su year if state == "`s'" & change_in_min_wage >= 0.5 & year > 2010, meanonly
        if r(N) > 0 {
            replace treat_year = r(min) if state == "`s'"
            replace treated = 1 if state == "`s'"
        }
    }
}

*--------------------------------------------------------------*
* 3. Set Panel Structure
*--------------------------------------------------------------*
encode state, gen(state_id)
xtset state_id year

*--------------------------------------------------------------*
* 4. Run csdid Regression (NO CONTROLS)
*--------------------------------------------------------------*
csdid labor_force_participation_rate ///
    , ivar(state_id) time(year) gvar(treat_year) ///
    method(dripw) wboot reps(500) seed(12345)

* Store the results
eststo lfpr_main

*--------------------------------------------------------------*
* 5. Run Event Study
*--------------------------------------------------------------*
csdid_estat event

* Save event study results from returned matrix
matrix M = r(table)'
clear
svmat M, names(col)

*--------------------------------------------------------------*
* 6. Clean Event Study Output
*--------------------------------------------------------------*
gen eventtime = -2 + _n
replace eventtime = -99 if _n == 1
replace eventtime = 99 if _n == 2
rename b attgt
keep if inrange(eventtime, 1, 7)
replace eventtime = eventtime - 5

*--------------------------------------------------------------*
* 7. Plot Event Study
*--------------------------------------------------------------*
twoway ///
    (rarea attgt se eventtime, color(gs12)) ///
    (connected attgt eventtime, lcolor(blue) mcolor(blue)) ///
    , ///
    yline(0, lcolor(black)) ///
    xline(0, lpattern(dash)) ///
    ylabel(, grid) ///
    xlabel(-4(1)2, grid) ///
    title("Effect of $0.50 Minimum Wage Increase on Labor Force Participation Rate") ///
    ytitle("ATT on LFPR (%)") ///
    xtitle("Years Relative to Treatment") ///
    legend(off)

*--------------------------------------------------------------*
* 8. Save the Graph
*--------------------------------------------------------------*
capture mkdir "Output/Results/Figures"
graph export "Output/Results/Figures/event_study_lfpr_no_controls.png", replace
graph export "Output/Results/Figures/event_study_lfpr_no_controls.pdf", replace

*--------------------------------------------------------------*
* 9. Save ATT Summary Table
*--------------------------------------------------------------*
capture mkdir "Output/Results/Tables"
esttab lfpr_main using "Output/Results/Tables/att_summary_table_lfpr_no_controls.txt", ///
    se b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) label replace

*--------------------------------------------------------------*
* DONE for LFPR no controls
*--------------------------------------------------------------*










*--------------------------------------------------------------*
* Robustness Check - Unemployment Rate (No Controls)
*--------------------------------------------------------------*

* 0. Clean start
clear all
set more off

*--------------------------------------------------------------*
* 1. Load Data
*--------------------------------------------------------------*
use "Data/AnalysisData/final_analysis_data.dta", clear

*--------------------------------------------------------------*
* 2. Create 50-cent Increase Treatment Variable
*--------------------------------------------------------------*
sort state year
gen lag_state_min_wage = state_min_wage[_n-1] if state == state[_n-1]
gen change_in_min_wage = state_min_wage - lag_state_min_wage
gen treat_year = .
gen treated = 0

levelsof state, local(states)
foreach s of local states {
    quietly {
        su year if state == "`s'" & change_in_min_wage >= 0.5 & year > 2010, meanonly
        if r(N) > 0 {
            replace treat_year = r(min) if state == "`s'"
            replace treated = 1 if state == "`s'"
        }
    }
}

*--------------------------------------------------------------*
* 3. Set Panel Structure
*--------------------------------------------------------------*
encode state, gen(state_id)
xtset state_id year

*--------------------------------------------------------------*
* 4. Run Staggered DiD (csdid) WITHOUT Controls
*--------------------------------------------------------------*
csdid unemployment_rate, ///
    ivar(state_id) time(year) gvar(treat_year) ///
    method(dripw) wboot reps(500) seed(12345)

* Store results
eststo unemp_main

*--------------------------------------------------------------*
* 5. Run Event Study
*--------------------------------------------------------------*
csdid_estat event

* Save event study results
matrix M = r(table)'
clear
svmat M, names(col)

*--------------------------------------------------------------*
* 6. Clean Event Study Output
*--------------------------------------------------------------*
gen eventtime = -2 + _n
replace eventtime = -99 if _n == 1
replace eventtime = 99 if _n == 2

rename b attgt
* se already correctly named

keep if inrange(eventtime, 1, 7)
replace eventtime = eventtime - 5

*--------------------------------------------------------------*
* 7. Plot Event Study
*--------------------------------------------------------------*
twoway ///
    (rarea attgt se eventtime, color(gs12)) ///
    (connected attgt eventtime, lcolor(blue) mcolor(blue)) ///
    , ///
    yline(0, lcolor(black)) ///
    xline(0, lpattern(dash)) ///
    ylabel(, grid) ///
    xlabel(-4(1)2, grid) ///
    title("Effect of $0.50 Minimum Wage Increase on Unemployment") ///
    ytitle("ATT on Unemployment Rate (%)") ///
    xtitle("Years Relative to Treatment") ///
    legend(off)

*--------------------------------------------------------------*
* 8. Save the Graph
*--------------------------------------------------------------*
graph export "Output/Results/Figures/event_study_unemployment_no_controls.png", replace

* Save ATT Output Table
esttab unemp_main using "Output/Results/Tables/att_summary_table_unemployment_no_controls.txt", ///
    se b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) label replace

	
	
	
	
	
	
*--------------------------------------------------------------*
* Robustness Check: 75-Cent Minimum Wage Increase
*--------------------------------------------------------------*

clear all
set more off

*--------------------------------------------------------------*
* 1. Load Data
*--------------------------------------------------------------*
use "Data/AnalysisData/final_analysis_data.dta", clear

*--------------------------------------------------------------*
* 2. Create 75-cent Increase Treatment Variable
*--------------------------------------------------------------*
sort state year
gen lag_state_min_wage = state_min_wage[_n-1] if state == state[_n-1]
gen change_in_min_wage = state_min_wage - lag_state_min_wage
gen treat_year_75 = .
gen treated_75 = 0

levelsof state, local(states)
foreach s of local states {
    quietly {
        su year if state == "`s'" & change_in_min_wage >= 0.75 & year > 2010, meanonly
        if r(N) > 0 {
            replace treat_year_75 = r(min) if state == "`s'"
            replace treated_75 = 1 if state == "`s'"
        }
    }
}

*--------------------------------------------------------------*
* 3. Set Panel Structure
*--------------------------------------------------------------*
encode state, gen(state_id)
xtset state_id year

*--------------------------------------------------------------*
* 4. Run Staggered DiD (csdid) with Controls
*--------------------------------------------------------------*
csdid employment_population_ratio ///
    unemployment_rate disposable_income_, ///
    ivar(state_id) time(year) gvar(treat_year_75) ///
    method(dripw) wboot reps(500) seed(12345)

* Save ATT estimate
eststo emp_75c

*--------------------------------------------------------------*
* 5. Event Study
*--------------------------------------------------------------*
csdid_estat event
matrix M = r(table)'
clear
svmat M, names(col)

gen eventtime = -2 + _n
replace eventtime = -99 if _n == 1
replace eventtime = 99 if _n == 2
rename b attgt
keep if inrange(eventtime, 1, 7)
replace eventtime = eventtime - 5

*--------------------------------------------------------------*
* 6. Plot Event Study
*--------------------------------------------------------------*
twoway ///
    (rarea attgt se eventtime, color(gs12)) ///
    (connected attgt eventtime, lcolor(blue) mcolor(blue)) ///
    , ///
    yline(0, lcolor(black)) ///
    xline(0, lpattern(dash)) ///
    ylabel(, grid) ///
    xlabel(-4(1)2, grid) ///
    title("Effect of $0.75 Minimum Wage Increase on Employment") ///
    ytitle("ATT on Employment-Population Ratio (%)") ///
    xtitle("Years Relative to Treatment") ///
    legend(off)

*--------------------------------------------------------------*
* 7. Save Outputs
*--------------------------------------------------------------*
capture mkdir "Output/Results/Figures"
capture mkdir "Output/Results/Tables"

graph export "Output/Results/Figures/event_study_plot_75c.png", replace
graph export "Output/Results/Figures/event_study_plot_75c.pdf", replace

esttab emp_75c using "Output/Results/Tables/att_summary_table_75c.txt", ///
    se b(3) se(3) star(* 0.10 ** 0.05 *** 0.01) label replace

*--------------------------------------------------------------*
* Done!
*--------------------------------------------------------------*









*--------------------------------------------------------------*
* 0. Clean start
*--------------------------------------------------------------*
clear all
set more off

*--------------------------------------------------------------*
* 1. Load Data
*--------------------------------------------------------------*
use "Data/AnalysisData/final_analysis_data.dta", clear

*--------------------------------------------------------------*
* 2. Create 25-cent Increase Treatment Variable
*--------------------------------------------------------------*
sort state year
gen lag_state_min_wage = state_min_wage[_n-1] if state == state[_n-1]
gen change_in_min_wage = state_min_wage - lag_state_min_wage
gen treat_year = .
gen treated = 0

levelsof state, local(states)
foreach s of local states {
    quietly {
        su year if state == "`s'" & change_in_min_wage >= 0.25 & year > 2010, meanonly
        if r(N) > 0 {
            replace treat_year = r(min) if state == "`s'"
            replace treated = 1 if state == "`s'"
        }
    }
}

*--------------------------------------------------------------*
* 3. Set Panel Structure
*--------------------------------------------------------------*
encode state, gen(state_id)
xtset state_id year

*--------------------------------------------------------------*
* 4. Run Staggered DiD (csdid) with Controls
*--------------------------------------------------------------*
csdid employment_population_ratio ///
    unemployment_rate disposable_income_, ///
    ivar(state_id) time(year) gvar(treat_year) ///
    method(dripw) wboot reps(500) seed(12345)

*--------------------------------------------------------------*
* 5. Run Event Study
*--------------------------------------------------------------*
csdid_estat event
matrix M = r(table)'
clear
svmat M, names(col)

*--------------------------------------------------------------*
* 6. Clean Event Study Output
*--------------------------------------------------------------*
gen eventtime = -2 + _n
replace eventtime = -99 if _n == 1
replace eventtime = 99 if _n == 2
rename b attgt
keep if inrange(eventtime, 1, 7)
replace eventtime = eventtime - 5

*--------------------------------------------------------------*
* 7. Plot Event Study
*--------------------------------------------------------------*
twoway ///
    (rarea attgt se eventtime, color(gs12)) ///
    (connected attgt eventtime, lcolor(blue) mcolor(blue)) ///
    , ///
    yline(0, lcolor(black)) ///
    xline(0, lpattern(dash)) ///
    ylabel(, grid) ///
    xlabel(-4(1)2, grid) ///
    title("Effect of $0.25 Minimum Wage Increase on Employment") ///
    ytitle("ATT on Employment-Population Ratio (%)") ///
    xtitle("Years Relative to Treatment") ///
    legend(off)

*--------------------------------------------------------------*
* 8. Save the Graph
*--------------------------------------------------------------*
capture mkdir "Output/Results/Figures"
graph export "Output/Results/Figures/event_study_plot_25c.png", replace





*--------------------------------------------------------------*
* 0. Clean start
*--------------------------------------------------------------*
clear all
set more off

*--------------------------------------------------------------*
* 1. Load Data
*--------------------------------------------------------------*
use "Data/AnalysisData/final_analysis_data.dta", clear

*--------------------------------------------------------------*
* 2. Create 1-dollar Increase Treatment Variable
*--------------------------------------------------------------*
sort state year
gen lag_state_min_wage = state_min_wage[_n-1] if state == state[_n-1]
gen change_in_min_wage = state_min_wage - lag_state_min_wage
gen treat_year = .
gen treated = 0

levelsof state, local(states)
foreach s of local states {
    quietly {
        su year if state == "`s'" & change_in_min_wage >= 1.00 & year > 2010, meanonly
        if r(N) > 0 {
            replace treat_year = r(min) if state == "`s'"
            replace treated = 1 if state == "`s'"
        }
    }
}

*--------------------------------------------------------------*
* 3. Set Panel Structure
*--------------------------------------------------------------*
encode state, gen(state_id)
xtset state_id year

*--------------------------------------------------------------*
* 4. Run Staggered DiD (csdid) with Controls
*--------------------------------------------------------------*
csdid employment_population_ratio ///
    unemployment_rate disposable_income_, ///
    ivar(state_id) time(year) gvar(treat_year) ///
    method(dripw) wboot reps(500) seed(12345)

*--------------------------------------------------------------*
* 5. Run Event Study
*--------------------------------------------------------------*
csdid_estat event
matrix M = r(table)'
clear
svmat M, names(col)

*--------------------------------------------------------------*
* 6. Clean Event Study Output
*--------------------------------------------------------------*
gen eventtime = -2 + _n
replace eventtime = -99 if _n == 1
replace eventtime = 99 if _n == 2
rename b attgt
keep if inrange(eventtime, 1, 7)
replace eventtime = eventtime - 5

*--------------------------------------------------------------*
* 7. Plot Event Study
*--------------------------------------------------------------*
twoway ///
    (rarea attgt se eventtime, color(gs12)) ///
    (connected attgt eventtime, lcolor(blue) mcolor(blue)) ///
    , ///
    yline(0, lcolor(black)) ///
    xline(0, lpattern(dash)) ///
    ylabel(, grid) ///
    xlabel(-4(1)2, grid) ///
    title("Effect of $1.00 Minimum Wage Increase on Employment") ///
    ytitle("ATT on Employment-Population Ratio (%)") ///
    xtitle("Years Relative to Treatment") ///
    legend(off)

*--------------------------------------------------------------*
* 8. Save the Graph
*--------------------------------------------------------------*
capture mkdir "Output/Results/Figures"
graph export "Output/Results/Figures/event_study_plot_1dollar.png", replace
